<template>
  <div class="flex justify-center pt-4" v-if="useStore.disclaimer_agree==false" >
     <el-card class="box-card w-1/2 align dark:bg-black" >
        <h3>免责声明</h3>
        <el-input v-model="disclaimer_txt" type="textarea"  :rows="20"  ></el-input>
         
        <div class="flex justify-end pt-2">
           <el-form-item >              
              <el-button  type="primary"  @click="discla_Handle()">确定</el-button>
           </el-form-item>
        </div>
    </el-card>
  </div>
</template>


<script setup>
import {ref, onMounted, getCurrentInstance, watch, inject} from 'vue';
import { ElMessage ,ElMessageBox ,ElDrawer } from 'element-plus'
import { useBdStore } from '@/stores/bdStore.js';
const useStore = useBdStore()
const disclaimer_txt = ref("")
const disclaimer_agree = ref("")
inject('pydisclaimer')
onMounted(()=>{
    setTimeout(()=>{
       pydisclaimer2();
    },1500)
})

const pydisclaimer2 = (() => {
   
    window.pywebview.api.py_disclaimer().then((r) => {
        disclaimer_txt.value = r;
        useStore.disclaimer_txt = r;

        window.pywebview.api.pymaterial_getTbVariables('disclaimer_agree').then((r) => {
            if (r.code == -1000) {
                disclaimer_agree.value = false
                useStore.disclaimer_agree = false
            } else {
                disclaimer_agree.value = true
                useStore.disclaimer_agree = true
            }
        })
    })

})

const discla_Handle = (()=>{
    window.pywebview.api.pymaterial_updateTbVariables({'key':'disclaimer_agree','value':'true','category':'app'}).then((r) => {
         useStore.disclaimer_agree = true
         // pydisclaimer();

    })
})


</script>